﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CIS470MetricsTracking
{
    public class ReportController
    {
        public DataTable getReportResults(string project_name, string report_name)
        {
            string query;
            DataSet ds = new DataSet();
            DataTable dt = new DataTable();

            // fill report table
            query = "select reportDate, actualResult, actualMetric, parameter from Q_ProjectReportedResults where projectName='" + 
                project_name + "' AND indicatorName='" + report_name + "'";

            ds = ControllerManager.data_controller.executeSelectQuery(query);
            dt = ds.Tables[0];

            return dt;
        }

        public DataTable getReportBaselines(string project_name, string report_name)
        {
            string query;
            DataSet ds = new DataSet();
            DataTable dt = new DataTable();

            // fill report table
            query = "select baselineDate, baseline, actualMetric, parameter from Q_ProjectBaselines where projectName='" +
                project_name + "' AND indicatorName='" + report_name + "'";

            ds = ControllerManager.data_controller.executeSelectQuery(query);
            dt = ds.Tables[0];

            return dt;
        }

        public DataTable getReportDetails(string project_name, string report_name)
        {
            string query;
            DataSet ds = new DataSet();
            DataTable dt = new DataTable();

            // fill details table;
            query = "select distinct actualMetric, parameter from Q_ProjectReportedResults where projectName='" + project_name + "' and indicatorName='" + report_name + "'";
            ds = ControllerManager.data_controller.executeSelectQuery(query);
            dt = ds.Tables[0];            
            
            return dt;
        }
    }
}
